< previous page page_277 next page >

Page 277
5. Make a set of control arrays for lblColor and sldColor. To do so, hold down the Ctrl key and click both lblColor and sldColor. Choose Edit, Copy. Then choose Edit, Paste to paste the copied controls onto the form. You then are presented with a dialog box asking whether you want to create a control array. Click Yes. (Control arrays are covered in detail in Chapter 13, "Working with Control Arrays.")
6. Add a third element to each control array by choosing Paste again.
7. Using the Properties window, set the caption of lblColor(0) to Red:, the caption of lblColor(1) to Green:, and lblColor(2) to Blue:.
8. Arrange the lblColor() and sldColor() control arrays on the form as shown in Figure 12.27.
0277-01.jpg
Figure 12.27
The main form of the color blender
project contains an array of slider controls.
After you set up the interface of the program, you need to add some code to a couple of events to make the program work. The first event is the Load event of the form, as shown in Listing 12.5. This event sets the initial condition of the program.
Listing 12.5 SLIDERS.ZIPInitializing the Program in the Load Event of the Form
Private Sub Form_Load()

    Dim nCount As Integer
    Dim lRed As Long, lGreen As Long, lBlue As Long

'Set up the sliders
    For  nCount = 0 To 2
        sldColor(nCount ).Min = 0
        sldColor(nCount ).Max = 255

        sldColor(nCount ).TickFrequency = 4
    Next  nCount

    'Initialize the color of the form
    'control. (This will set the color to black. RGB(0,0,0))
    Me.BackColor = RGB(lRed, lGreen, lBlue)

End Sub

 
< previous page page_277 next page >